#pragma once

#include <string>
#include "def.h"

class Dbs
{
public:
    Dbs();
    virtual ~Dbs();
    virtual bool Open()=0;
    virtual void Close()=0;

protected:
    virtual bool Inquiry(const char* sql) = 0;
    virtual bool Exec(const char* sql) = 0;
public:
    // table
    virtual bool MakeTable()=0;
    virtual int GetCount(const char* sql) = 0;
    virtual void SetTableName(const std::string& name) = 0;
    // file 
    virtual int  SelectFileInfo(const std::string& relative, StFileInfo& info) = 0;
    virtual bool InsertFileInfo(const StFileInfo* info, int size) = 0;
    virtual bool UpdateFileInfo(const StFileInfo* info, int size) =0;
    virtual bool SelectFileLatestPacket(int64_t& packet) = 0;

    // version
    virtual int SelectVersionInfo(const std::string& app, StVersionInfo& info) = 0;
    virtual bool InsertVersionInfo(const StVersionInfo& info) = 0;
    virtual bool UpdateVersionInfo(const StVersionInfo& info) = 0;
};

